Subject: Re: How to detach from cli.
From: [email-masked] (Christoph Feck IRZ)
Date: Thu, 17 Feb 1994 15:53:46 GMT
Newsgroups: comp.sys.amiga.programmer

In article <[email-masked]>, [email-masked]  (Marco van den Hout) writes:
> "[email-masked] (Christoph Feck IRZ)" says about detaching:
>  
> 1) clear the cli_module pointer... okay that's easy.. that prevents the
>    program to be unloaded when it exits..
> 2) start a process (using CreateNewProc) with the same seglist and a
>    different entry point...
>  
> This I don't get - RKRM Includes & Autodocs says  NP_SegList and
> NP_Entry are mutually exclusive.. then how can you use the same
> seglist while starting at another entry point? Only way I see is to
> check if the program was already started at the beginning..

Either:
Use NP_Entry.  Send the new process a startup message
(to pr_MsgPort).  In this message place a pointer to the
seglist.  The called task can free this seglist later.
Be sure to exit the calling task only after you got an 'OK'
reply from the detached task.  If your program isn't going
to be 'resident' (reentrant), you can avoid all the message
passing and just store the segment pointer in a variable,
which is referenced via A4.  The entry function must then
use __saveds of course.

Or:
In the non-reentrant case, you can use NP_SegList, and check
a global variable first (like you suggested).

> By the way, I'm trying to program this in assembler, not in C.

That doesn't matter :)

Ciao,
Christoph

3k// Christoph Feck, TowerSystems
\X/ Amiga - Intuition inside.